<?php

namespace app\common\model;

use think\Model;

class QbankName extends Model
{
    //
    protected $table = 'bk_qbank_name';

    public function ExamList()
    {
        return $this->hasMany('ExamStudent', 'exam_type', 'bid');
    }

    public function bankList()
    {
        $bank_list = $this->order('bid', 'esc')->select();

        foreach ($bank_list as $item) {
            $arr[] = $item;

        }

        return $arr;
    }

    public function sort($data, $bid = 0, $level = 0)
    {
        static $arr = array();
        foreach ($data as $k => $v) {
            if ($v['bid'] == $bid) {
                $v['level'] = $level;
                $arr[] = $v;
                $this->sort($data, $v['id'], $level + 1);
            }
        }
        return $arr;
    }
    public function ques(){
        return $this->hasMany('Qbank','qbank','bid');
    }
}
